class Player(object):
    numbers = 0  # 类属性 （不属于单个实例）
    def __init__(self,name,age,city): # 初始化函数（构造函数
        self.name = name
        self.age = age
        self.city = city
        Player.numbers += 1  # 统计玩家人数

tom = Player('tom',18,'苏州')
# print(tom.__dict__)
# print("欢迎王者游戏的第%d个玩家注册游戏："% Player.numbers)
lily = Player('lily',18,'苏州')
# print("欢迎王者游戏的第%d个玩家注册游戏："% Player.numbers)


class weapon(object):
    numbers = 0  # 武器数
    max_damage = 10000
    levels = ['青铜','白银','黄金','钻石','王者']
    def __init__(self,name,damage,level):
        self.name = name
        self.damage = damage
        self.level = level
        weapon.numbers += 1
        if damage > weapon.max_damage:
            raise Exception("你设置的伤害值已超出最大值")
        if level not in weapon.levels:
            raise Exception("段位设置错误！")
try:
    gun = weapon('magic',10000,'王者')
    arrow = weapon('arrow',450,'青铜')
    print(arrow.numbers)
except Exception as e:
    print(e)